//
// Created by the DataSnap proxy generator.
// 11/04/2012 13:34:15
//

unit Unit1;

interface

uses DBXCommon, DBXClient, DBXJSON, DSProxy, Classes, SysUtils, DB, SqlExpr, DBXDBReaders, DBXJSONReflect;

type
  TServerMethods1Client = class(TDSAdminClient)
  private
    FEchoStringCommand: TDBXCommand;
    FReverseStringCommand: TDBXCommand;
    FGetTextFileCommand: TDBXCommand;
    FClickBtnCommand: TDBXCommand;
    FCclipboardCommand: TDBXCommand;
  public
    constructor Create(ADBXConnection: TDBXConnection); overload;
    constructor Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean); overload;
    destructor Destroy; override;
    function EchoString(Value: string): string;
    function ReverseString(Value: string): string;
    procedure GetTextFile(Msg: string);
    function ClickBtn(KeyNum: Integer): Boolean;
    procedure Cclipboard(Clip: string);
  end;

implementation

function TServerMethods1Client.EchoString(Value: string): string;
begin
  if FEchoStringCommand = nil then
  begin
    FEchoStringCommand := FDBXConnection.CreateCommand;
    FEchoStringCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FEchoStringCommand.Text := 'TServerMethods1.EchoString';
    FEchoStringCommand.Prepare;
  end;
  FEchoStringCommand.Parameters[0].Value.SetWideString(Value);
  FEchoStringCommand.ExecuteUpdate;
  Result := FEchoStringCommand.Parameters[1].Value.GetWideString;
end;

function TServerMethods1Client.ReverseString(Value: string): string;
begin
  if FReverseStringCommand = nil then
  begin
    FReverseStringCommand := FDBXConnection.CreateCommand;
    FReverseStringCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FReverseStringCommand.Text := 'TServerMethods1.ReverseString';
    FReverseStringCommand.Prepare;
  end;
  FReverseStringCommand.Parameters[0].Value.SetWideString(Value);
  FReverseStringCommand.ExecuteUpdate;
  Result := FReverseStringCommand.Parameters[1].Value.GetWideString;
end;

procedure TServerMethods1Client.GetTextFile(Msg: string);
begin
  if FGetTextFileCommand = nil then
  begin
    FGetTextFileCommand := FDBXConnection.CreateCommand;
    FGetTextFileCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FGetTextFileCommand.Text := 'TServerMethods1.GetTextFile';
    FGetTextFileCommand.Prepare;
  end;
  FGetTextFileCommand.Parameters[0].Value.SetWideString(Msg);
  FGetTextFileCommand.ExecuteUpdate;
end;

function TServerMethods1Client.ClickBtn(KeyNum: Integer): Boolean;
begin
  if FClickBtnCommand = nil then
  begin
    FClickBtnCommand := FDBXConnection.CreateCommand;
    FClickBtnCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FClickBtnCommand.Text := 'TServerMethods1.ClickBtn';
    FClickBtnCommand.Prepare;
  end;
  FClickBtnCommand.Parameters[0].Value.SetInt32(KeyNum);
  FClickBtnCommand.ExecuteUpdate;
  Result := FClickBtnCommand.Parameters[1].Value.GetBoolean;
end;

procedure TServerMethods1Client.Cclipboard(Clip: string);
begin
  if FCclipboardCommand = nil then
  begin
    FCclipboardCommand := FDBXConnection.CreateCommand;
    FCclipboardCommand.CommandType := TDBXCommandTypes.DSServerMethod;
    FCclipboardCommand.Text := 'TServerMethods1.Cclipboard';
    FCclipboardCommand.Prepare;
  end;
  FCclipboardCommand.Parameters[0].Value.SetWideString(Clip);
  FCclipboardCommand.ExecuteUpdate;
end;


constructor TServerMethods1Client.Create(ADBXConnection: TDBXConnection);
begin
  inherited Create(ADBXConnection);
end;


constructor TServerMethods1Client.Create(ADBXConnection: TDBXConnection; AInstanceOwner: Boolean);
begin
  inherited Create(ADBXConnection, AInstanceOwner);
end;


destructor TServerMethods1Client.Destroy;
begin
  FreeAndNil(FEchoStringCommand);
  FreeAndNil(FReverseStringCommand);
  FreeAndNil(FGetTextFileCommand);
  FreeAndNil(FClickBtnCommand);
  FreeAndNil(FCclipboardCommand);
  inherited;
end;

end.

